Assignment 1

Part 1 - Present an exploratory data analysis of the dataset that you selected

For this assignment I chose to use the car dataset (https://www.kaggle.com/jessicali9530/stanford-cars-dataset). The Cars dataset contains 16,185 images of 196 classes of cars. The data is split into 8,144 training images and 8,041 testing images, where each class has been split roughly in a 50-50 split, that means that the data is balanced. Classes are typically at the level of Make, Model, Year, ex. 2012 Tesla Model S or 2012 BMW M3 coupe. The images in the train part and in the test part are in different sizes, so there is a need to preprocesse them.

Lets look at some of the train csv data -
train_csv_data.png

train_images.png

Lets look at some of the car classes -
some_classifications.png

Example of 2 cars that are easily separable: easy%20example.png

Example of more similar cars: hard%20example.png

tuples_exmaple.png

train DataFrame - train%20dataframe.png

test_df.png

part 2 - Form a neural network graph

First Model

training_logs - logs_model_1_1.png

logs_model_1_2.png

Let's look at the train loss vs validation loss of the first model:

graph 1:

loss_graph_model_1.png

graph 2 - acc_graph_model_1.png

We can see that from the start to the end the model did not improve at all. I can assume that reducing the image size can impair the learning of the model. Another things is the model is very small, only 2 conv layers and 2 fc layers, maybe the model could get better if it had more layers and a Batch Normalization layer and changing conv parameters such as kernel size and stride.

Second Model

training logs - logs_mode_2_1.png

logs_model_2_2.png

Let's look at the train loss vs validation loss of the second model:

graph 3 - loss_graph_model_2.png

Now let's look at the train, validation & test accuracy of the second model:

graph 4 - acc_graph_model_2.png

prediction of car images that were the right class label:

correct_preds_model_2.png

On the right is the car that was most detected than the others cars and on the left is the car that was least detected by the model:

good_detect_bad_detect_model_2.png

It can be seen that the second model was able to achieve better results than the first model. The results of the test were still low compared to the results of the train and validation. I'ts seems that the model was overfitted. As I suspected the 'Acura TL Sedan 2012' was a hard class to detcted (did not get detected at all), we can see from the previous graph that class 'Acura TSX Sedan 2012' was also not detected.

part 3 - Use a pretrained model

training logs - logs_model_3_1.png

logs_model_3_2.png

graph 5 - loss_graph_model_3.png

graph 6 - acc_graph_model_3.png

This model got better results then the previous 2 models but the test accuracy is still low. I will try to add another linear layer at the end because the last layer has 4096 in features that connect to 196 nodes, add another drop layer and increase the number of epochs.

training logs - logs_model_4_1.png

logs_model_4_2.png

At first it seems like the model is trying to fight an overfit problem, but as the folds contiue it looks like the model is diverging, so i'm not sure if it was able to classify cars to the right class.

graph 7 - loss_graph_model_4.png

graph 8 - acc_graph_model_4.png

model_4_true_preds.png

In total the the assignment was interesting, it was the first time I made a NN so it was not easy. It was nice to build my own network and to used an exsiting one and to see the difference in the results.